<?php 
class sec_news extends Controller {

	var $event 				= '';
	var	$obj_sec_news		= '';
	var $m_nid				= '';
	var $m_language			= 'eng';
	/* Paging*/
	var $ctr_name			= '';
	var	$ncurrent_page		= 1;
	var	$nrow_per_page		= 15;
	var $ntotal_row			= 0;
	var $total_page			= 0;
	/* Paging*/
	var $nid_section		= '';
	var $nid_cat			= '';
	
	var	$title					= '';
	var	$tags					= '';
	var	$description			= ''; 

function sec_news()
	{
		parent::Controller();	
		session_start();
		
		$this->load->database();	
		$this->load->helper('ap_function');
		$this->load->helper('ap_object');
		$this->load->helper('ap_html');
		$this->load->helper('ap_view_helper');
		$this->load->helper('ap_db');
		$this->load->helper('ap_module');
		$this->load->language('ap', 'eng');
	}

// Dinh nghia ham rut gon khi set language cho cac label.
// 
private function m_language_key($str_key)
{
	return $this->lang->line('lbl.sec_news.'.$str_key);
}

function index()
{
	$this->do_process();
}

function do_process() 
{
	$this->get_data(); 		
	$this->caculate_data(); 		
	$this->do_business(); 		
	$this->destroy_data();
}
function get($nid)	
{
	$this->nid_section = $nid;
	$this->do_process();
}

function page ($nid, $page)
{
	$this->ncurrent_page	= $page;
	$this->nid_section = $nid;
	$this->do_process();
}
	
private function get_data()
{  
	
}
	
private function caculate_data()
{
	$this->load->language('ap', $this->m_language);
	$str_where_sec_news			= $this->get_where_sec_news_string();
	
	$this->ntotal_row			= Oget_count_sec_news($str_where_sec_news);
	$this->total_page			= Fget_total_page($this->nrow_per_page, $this->ntotal_row);		
	$this->obj_data				= Oget_total_sec_news($str_where_sec_news,'nid','asc',$this->nrow_per_page,$this->ncurrent_page);
	
	$this->event				= $this->event == ''?'view':$this->event;
}

private function do_business()
{	
	$data['ntotal_row'] 	= $this->ntotal_row;
	$data['ncurrent_page'] 	= $this->ncurrent_page;
	$data['total_page'] 	= $this->total_page;
	$data['nrow_per_page'] 	= $this->nrow_per_page;
	$data['nid_section'] 	= $this->nid_section;
	
	$data['title']			= $this->title;
	$data['tags']			= $this->tags;
	$data['description']	= $this->description;
	$data['g_ishome']		= 0;	
	$data['obj_data'] 		= $this->obj_data;
	$this->load->view('sec_news/index',$data);
		
		
}
	
private function destroy_data()
{
			
}
private function get_where_sec_news_string()
{
//		$str		= 'where nstatus = "1"';	
		if($this->nid_section =='')
			redirect(base_url());
		$str = ' ';
		if($this->nid_section != '')
		$str .= ' AND nid_section_news = '.$this->nid_section;
		
		return $str ;
}

}